#from django.contrib.auth.models import User
from django.db import models
from django.forms import ModelForm
import uuid

# Create your models here.
class BMCommonModel(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    createDate = models.DateTimeField(auto_now=False, auto_now_add=True)
    updateDate = models.DateTimeField(auto_now=True, auto_now_add=False)
    #user = models.ForeignKey(User,on_delete=models.CASCADE)
    class Meta:
        abstract = True

class DomainZoneModel(BMCommonModel):
    domain = models.CharField(max_length=255)
    #user = models.ForeignKey(User,on_delete=models.CASCADE)

class BookmarkerModel(BMCommonModel):
    url = models.CharField(max_length=255)
    title = models.CharField(max_length=255)
    icon = models.CharField(max_length=255)
    domainZone = models.ForeignKey(DomainZoneModel,on_delete=models.CASCADE,related_name='bookmarker')
    domain = models.CharField(max_length=255)

class BookmarkerFileModel(BMCommonModel):
    fileName = models.CharField(max_length=255)
    uploadFile = models.FileField(upload_to='yunbookmarker/static/uploads/')

class BookmarkerModelForm(ModelForm):
    class Meta:
        model = BookmarkerModel
        fields = ['url','title','domain']

class BookmarkerFileModelForm(ModelForm):
    class Meta:
        model = BookmarkerFileModel
        fields = ['uploadFile']

class DomainZoneModelForm(ModelForm):
    class Meta:
        model = DomainZoneModel
        fields = ['domain']
